home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
hc
/
windoid2.sit
/
Windoid #2.TXT
Wrap
Text File
|
1988-11-29
|
18KB
|
356 lines
Windoid
Issue #2
The Publication for the Informed HyperCard User Editor: David Leffler
WINDOID provides an opportunity for its readers to contribute to the ongoing growth and excellence of
HyperCard. With your assistance we can continue to bring to HYPERCard added depth and functionality.
In the back of every issue will be a form for you to keep by your Macintosh. This form will give you
the unique opportunity to be able to participate directly in the continued development of HyperCard.
If you have a bug, suggestion, comment, or just want to know the best way to do something in
HyperCard, you can fill out the form and send it to:
AHUG c/o David Leffler, Apple Computer, Inc., MS/27-AQ, 20525 Mariani Ave., Cupertino, CA 95014.
Or copy the format and AppleLink it to HYPERBUG$.
We will read all the forms returned and address questions that are being asked by HyperCard users.
We will ask the team and provide you with an answer and publish the answers in this newsletter. In
this way we can gather information and provide for your needs in future versions of HyperCard.
WINDOID is trying to make a difference in the way that you work with HyperCard. We need your
input. What sort of stacks are you using, what kinds of stacks are you creating, and what are some
of the joys and frustrations you are experiencing. We really want to know!
Bill and Dan are very receptive to user input and this is your chance to make a difference in the
world.
In this second issue of WINDOID, we have listened to those who have made a contribution and have
needed information. In this issue we will address some of the areas that people have questioned us
about and talk in depth about importing text files.
Many people have large amounts of data stored in text files. They would like to move this
information into HyperCard stacks. There are many ways to import files, and we have included in this
issue what we feel addresses most of your needs. We have sifted through the many different ways our
users have needed to import files, and we have chosen a few of the most simple and flexible.
This issue will deal with import button scripts, and in the next issue we will deal with planning the
stack and the Universal Import Button by Gary Bond.
When importing text into HyperCard, you must consider how you want the text to appear. Should it
fill a single field? Should it create new fields and new cards for each imported text record? How
much of a field should you fill with text? Will it appear in scrolling fields? What kind of text
will be imported? These are all questions that need to be answered before you begin writing your
script. This article will explore the two kinds of text and answer some of these questions.
Two Kinds of Text
For the most part, there are two types of text files. The first is the common document file which is
usually nothing more than a Macwrite or Microsoft Word document saved as a text file. All of the
characters in this kind of file are usually in printable ASCII format.
The second kind of text file is sometimes generated by a database product such as Omnis or 4th
Dimension. This kind of file is broken down into two parts. These parts are records (which are
considered to be separate and distinct groups of information) and fields (which are sub-units of
information within records). A record can contain several fields with each field capable of holding
a different kind of information. In a mailing list for example, each person in the mailing list
would be a record in the database while the information about that person such as their name,
address, city, state, and zip would be fields of information within the individual records. Notice
that each record in this kind of file has the same number of fields.
Exploring Import Scripts
Below are some common scripts for reading and writing the first kind of text file:
Simple read from a text file:
on MouseUp
Open file filename
Repeat
Read from file filename for 16384 --fastest/most efficient read
If it is empty then exit repeat --leave when out of characters
Put it after var --continue to build a variable with incoming text
--Could also put after a field but must respect the 32K field limit
End repeat
Close file filename end mouseUp
Simple write to a text file:
on mouseUp
Open file filename
Write var to file filename
--Ex: Write field fieldname to file filename
--Ex: Write Msg to file filename
--Ex: Write the selection to file filename
Close file filename end mouseUp
Simple append to a text file:
on mouseUp
Open file filename
Repeat -- Must read current file info then add new info and write it out.
Read from file filename for 16384
If it is empty then exit repeat
Put it after var1
End Repeat
Put var2 & return after var1
Write var1 to file filename
Close file filename end mouseUp
When dealing with the second type of text file, it's necessary to get a little tricky. First of all,
to maintain the flavor of the original file, we have to do a little planning.
In examining the available list of objects in HyperCard, it becomes obvious that a card would make a
perfect record. In our mailing list example, each card could represent a different person. In fact,
with the addition of a few HyperCard text fields to hold field information from the text file, a
stack could serve as a nice representation of our original mailing list database.
Planning the Stack
Let's assume that our goal is to import our current mailing list into a HyperCard stack. We first
need to write our mailing list to a text file using the appropriate field and record separater
characters (these are usually TAB for fields and RETURN for records). This means that there will
need to be a CARRIAGE RETURN character following every record in the text file and a TAB character
following every field. Many current databases have the ability to export text in this manner.
"My mailing list" consists of 143 records (names). For each person in the list I keep the following
information:
1) Name 2) Address 3) City, State, Zip 4) Phone 5) Comment
In examining the mailing list, I can see that I have 143 records with each record broken down into
five fields. So we know that we will end up with 143 cards in the finished stack. And since each
card can share a similar background, we only need to create a total of five background fields into
which the data for each new card will be placed.
We start by creating a new stack with a new background and adding five background fields to that
card. When that is done, create a card button with the name IMPORT. Here's what the script for the
button might look like:
on mouseUp
Ask "Import from what file:" with empty
put it into filename --get filename and store it
Open file filename -- open the file
Repeat
Read from file filename until return -- get 1 record at a time
If it is empty then exit repeat --exit if there are no more records
put it into record --put the record text into a variable
DoMenu "New card" --create a new card
repeat with count = 1 to 5 --we have five fields so repeat five times
if offset(tab,record) > 0 then --last part of chunk has no delimiter
put char 1 to (offset(tab, record) -l) of record into bkgnd field count
else
put record into bkgnd field count --put last part of chunk
end if
delete char 1 to offset(tab,record) of record --zap chunk from record
end repeat
end repeat end mouseUp
The first part of the script gets the filename, stores it and opens the file. We then enter a repeat
loop which reads a single record, creates a new card and places the field information in the
appropriate fields. The inner repeat loop looks for the field delimiter (tab) in the record data and
grabs the chunk of characters from the beginning of the record to that delimiter. It then inserts
that chunk into the appropriate field. The chunk is then deleted from the variable and the loop
cycles back through until all chunks are placed in fields.
While this approach is reliable, it is also very slow and doesn't account for a number of problems
that might occur along the way. Consistent with our goal to provide you with the best, the next
WINDOID (Issue #3) continues this article in more depth. We will present a script for a universal
import button which does both kinds of import (text and data). To use it, you can type it into any
button script.
Power User Tips by Phil Wyman
1. The DoMenu command will execute DAs. For example, DoMenu "Calculator".
2. "It" is a local system variable, not a global.
3. "Set Cursor" command normally uses the following: "Set cursor to 1" = I-Beam "Set cursor to 2" =
crossbar "Set cursor to 3" = thick crossbar "Set cursor to 4" = watch "Set cursor to 5" - arrow or
browse tool
4. "Set lockmessages to true" does not work in the message box. This is because "lockmessages" is
turned off during idle. Therefore, lockmessages can only be used in a script.
5. If you don't see the menu bar on an application, Command-Spacebar will allow you to see and use
the menu bar.
6. Option-O both in and out of Fatbits will show you where opaque white exists on your card if
you're in Paint Tools.
7. Command-Drag sizes (elongates) a selected picture in HyperCard. Command-Shift-Drag will enlarge
and shrink the selected picture proportionally.
8. When you are trying to intercept an arrowkey, you must use the message "on arrowKey" with the
argument "var". Then you must see if "var" equals "left" or "right" or "up" or "down". For example:
on arrowkey var
if var = "left" then exit arrowkey
go next card
end arrowkey
9. If you have to declare many global variables at the beginning of your script, you can declare
them in the same line by separating them with a comma. For example, "global var1,var2,var3,var4".
10. You can edit your own patterns in the patern windoid by double-clicking on them. These changed
patterns will stay with the particular stack and not overlap into other stacks.
11. If a user-defined function uses the same name as a HyperCard function, HyperCard defaults to the
user-defined function. For example, if you have a function "average" that you have defined in a
stack script, HyperCard will use that function and not its own built-in average function.
12. If you want a miniature picture of a card, you can do Copy Card from the menu, then
Command-Shift-V to paste a miniature on your screen.
13. If you want to set more than one textstyle, you can say: "Set textstyle of button to
bold,italic,underline". Also, if you want to not have any textstyle after it has been set to a
certain style, you can say: "set textstyle of button to plain".
14. The user pressing Command-Period can stop any script, even if an ANSWER or ASK dialog is on the
screen.
15. Double-clicking on a word in the Script Editor or in a field selects the entire word.
16. In a script, you might not know how many levels deep you are in calls to other handlers that
have called you. "Exit to HyperCard" will pop you out of all sub-messages.
17. If you have had trouble getting the name of a card, here's the trick. Go to the card and ask:
"get the short name of this card". The short name will give you the name of the card, whereas the
long name will give you the entire pathway to the card.
18. "Repeat" or "Repeat Forever" will continue on until an exit repeat or an exit to HyperCard is
encountered.
19. In a field, drag with the Command key on a selection of text. HyperCard will put it into the
message box, and you can then execute it by hitting return.
20. If the user conacels an "ASK" dialog, HyperCard puts a null into the variable "it". You cna
therefore check and see if "it" is empty, thereby knowing that the user clicked CANCEL.
21. Once you have set a button to an icon, you can set the button to not have an icon by saying:
"set icon of button to zero".
22. Only a locked text field can receive mouse messages such as mouseUp, mouseDown, mouseWithin,
etc.
23. Two other characters work as HyperCard operators "greater than or equal" and "less than or
equal", as well as the more normal >= and <=. You get these characters by pressing Option-Greater
Than or Option-Less Than.
24. You can get rid of your screen altogether by "set visible of cardwindow to false".
25. Functions are not to be defined within message handlers.
Programming Functionkeys in HyperTalk By Robin Shank
The HyperTalk command "functionkey" allows you to associate a script with any of the function keys on
an extended keyboard. To program a functionkey, use the following format:
on functionkey thekey
if thekey is 5 then
--add any script
end if
if thekey is 6 then
put the heapspace -- or whatever
end if end functionkey
You can put the script into a card, background, stack, or home script, depending on how widely you
want your functionkeys to be "detected".
The following script will make a functionkey that will automatically move anything selected on the
card into the background. The beauty of using type "x" with commandkey instead of domenu "cut" is
that it transcends the fact that the Edit menu reflects the object selected. The command key simply
calls that menu item, so it doesn't matter if it says "cut button" or "cut picture". I've installed
this script into my Home card, so that I can access it from any stack.
On functionkey whatkey
if whatkey is 6 then
type "x" with commandkey -- Cut whatever is selected
domenu "background" -- enter the background
type "v" with commandkey -- Paste it
domenu "background" -- leave the background
end if end functionkeys
Icon Maker 2.1
As you know, HyperCard comes with many different button ICONs ready for your immediate use. Just
double-click on any button while in the Button Tool and you will see a dialog box with a button
called Icon. Clicking on this button allows you to scroll through and choose one of many interesting
icons for your buttons. One thing users have wanted was the ability to create and install other
icons in their stacks. Icon Maker solves that problem. Now you can create Icons and put them into
stacks very easily. All you do is install Icon Maker in your System file and select it from your DA
menu. An empty (32 X 32) ICON sized square appears and is capable of copying anything you click on
within its boundaries. ICN#s (Finder Icons) are created when you just click your mouse and ICONS are
created if you press the command key and click. ICON resources are what HyperCard uses. You will be
asked via Standard File where you want the ICON. If you want to use it only in your personal stacks
you can click on your Home card. This makes the ICON available to all of your stacks that use your
Home card. If you want other people to enjoy your newly created ICON, you will have to install it
directly into the stacks you will be sharing. Pressing on the H key with the Icon Maker selection
square showing gives you HELP information. Pressing any other key cancels Icon Maker. IconMaker
allows you to use clipart, or create your own art work and turn it into usable ICONs for sharing in
five clicks of a mouse. This is a really great utility for HyperCard. Icon Maker 2.1 was created by
Steve Fine. I have spoken to Steve and he has allowed me to put Icon Maker 2.1 in the AHUG StackWare
shareware folder. If you come to the Cupertino AHUG meetings you will be able to take it and see if
it meets your needs just as you are invited to share in all of the stacks that we bring to our
meetings every other Thursday. If you are out of the area almost all Macintosh public domain
librarys have it. Steve only asks that if you like it to please send him a contribution so that he
may continue to develop useful tools for you. His address is
Steve Fine 504 Linden Rd. University Park, PA 16802
Editorial by David Leffler
I hope you have enjoyed reading WINDOID and have found it to be interesting and informative. We care
enough to take the time to give you the most up-to-date information about HyperCard, and we would
like to make a request for a little of your time. There is a form that follows this editorial;
please fill it out if you will. We are very interested in hearing from you. What sorts of stacks
are you using, what kind of stacks are you creating, and what are your joys and frustrations in using
HyperCard. You have the unique opportunity to communicate directly with Bill, Dan, and the entire
HyperCard development team. We really want to know what you would like to see in HyperCard and are
more than willing to give you what you want What we need to make this happen is your input. Let us
know what you think. We can address it in WINDOID or perhaps the next revision of HyperCard. You
can make a difference in the world by communicating with us. Don't pass up the opportunity.
The form:
Please use the following form to make a difference in the world:
Date: Name: Address: Phone #: Versions of:
a. HyperCard:
b. Associated software:
c. System Software:
1. System
2. Finder
3. ImageWriter file
4. LaserWriter file
5. Any others Type of Macintosh: Peripherals: Description of problem, suggestions or comments:
Please fill this form out as completely as possible and send it to:
AHUG c/o David Leffler Apple Computer, Inc. MS/27-AQ 20525 Mariani Ave. Cupertino, CA 95014.
Or copy the format and AppleLink it to:
HYPERBUG$
We thank you for your participation and know that you will be pleased to see your ideas, comments,
and suggestions appear in future issues of WINDOID, the publication for the informed HyperCard user.
--
Keith Rollin amdahl\ Sales Technical Support pyramid!sun !apple!keith
Apple Computer decwrl/
Disclaimer: I read this board for fun, not profit. Anything I say is from the result of reading
magazines, hacking, and soaking my head in acid.